package com.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.Book;
import com.bean.Page;
import com.service.BookService;
import com.service.impl.BookServiceImpl;

@WebServlet("/getBook.do")
public class GetBookServlet extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		int pageNum;
		int pageSize;
		try {
			pageNum =Integer.parseInt(req.getParameter("pageNum"));
			
		}catch(Exception e) {
			pageNum=1;
		}
		try {
			pageSize =Integer.parseInt(req.getParameter("pageSize"));
			
		}catch(Exception e) {
			pageSize=1;
		}
		BookService bs = new BookServiceImpl();
		Page<Book> page =bs.getAllBook(pageNum,pageSize);
		req.setAttribute("bookPage", page);
		req.getRequestDispatcher("book.jsp").forward(req, resp);
	}
}
